package com.qumitech.visualnovel.model.dto.script;

import com.qumitech.visualnovel.component.exception.BusinessException;
import com.qumitech.visualnovel.model.common.ResultEnum;
import org.apache.commons.lang3.StringUtils;

public enum EventIdEnum {
    BOOK_CLICK_RECOMMEND("book_click_recommend", ModuleTypeEnum.BOOK, EventTypeEnum.CLICK, "点击推荐位置/书籍"),
    BOOK_OTHER_LIKE("book_click_like", ModuleTypeEnum.BOOK, EventTypeEnum.OTHER, "书籍点赞"),
    BOOK_OTHER_COMMENT("book_click_comment", ModuleTypeEnum.BOOK, EventTypeEnum.OTHER, "书籍评论"),


    READ_CLICK_STORY("read_click_story", ModuleTypeEnum.READ, EventTypeEnum.CLICK, "点击书籍落地页阅读/解锁"),
    READ_VIEW_OPTION("read_view_option", ModuleTypeEnum.READ, EventTypeEnum.VIEW, "进入到选项"),
    READ_CLICK_OPTION("read_click_option", ModuleTypeEnum.READ, EventTypeEnum.CLICK, "点击选项"),
    READ_VIEW_CHAPTER("read_view_chapter", ModuleTypeEnum.READ, EventTypeEnum.VIEW, "章节阅读"),
    READ_VIEW_CHAPTER_FINISH("read_view_chapter_finish", ModuleTypeEnum.READ, EventTypeEnum.VIEW, "章节完成阅读"),
    READ_EXIT_OPTION("read_exit_option", ModuleTypeEnum.READ, EventTypeEnum.VIEW, "退出选项"),

    READ_OTHER_FIRST("read_other_first", ModuleTypeEnum.READ, EventTypeEnum.OTHER, "首次阅读该本书"),
    READ_OTHER_FIRST_CHAPTER_FINISH("read_other_first_chapter_finish", ModuleTypeEnum.READ, EventTypeEnum.OTHER, "首章完成"),
    READ_OTHER_CHAPTER_UNLOCK("read_other_chapter_unlock", ModuleTypeEnum.READ, EventTypeEnum.OTHER, "章节解锁"),
    READ_OTHER_OPTION_UNLOCK("read_other_option_unlock", ModuleTypeEnum.READ, EventTypeEnum.OTHER, "选项解锁"),


    TASK_VIEW_PAGE("task_view_page", ModuleTypeEnum.TASK, EventTypeEnum.VIEW, "浏览任务"),
    TASK_CLICK_REWARD("task_click_reward", ModuleTypeEnum.TASK, EventTypeEnum.CLICK, "点击领取任意任务"),

    RECHARGE_CLICK_HOME("recharge_click_home", ModuleTypeEnum.RECHARGE, EventTypeEnum.CLICK, "点击顶部充值入口"),
    RECHARGE_VIEW_POP("recharge_view_pop", ModuleTypeEnum.RECHARGE, EventTypeEnum.VIEW, "充值提示框弹出"),
    RECHARGE_CLICK_PURCHASE("recharge_click_purchase", ModuleTypeEnum.RECHARGE, EventTypeEnum.CLICK, "点击充值提示框购买按钮"),
    RECHARGE_CLICK_SELECT("recharge_click_select", ModuleTypeEnum.RECHARGE, EventTypeEnum.CLICK, "点击任意充值档位"),
    RECHARGE_SUCC("recharge_succ", ModuleTypeEnum.RECHARGE, EventTypeEnum.CLICK, "充值成功"),
    MYPAGE_CLICK_LOGIN("mypage_click_login", ModuleTypeEnum.MYPAGE, EventTypeEnum.CLICK, "游客账号时点击登录"),
    MYPAGE_CLICK_LOGIN_SELECT("mypage_click_login_select", ModuleTypeEnum.MYPAGE, EventTypeEnum.CLICK, "登录弹窗选择登录"),
    ;
    private String eventId;

    private ModuleTypeEnum moduleTypeEnum;

    private EventTypeEnum eventType;

    private String remark;

    EventIdEnum(String eventId, ModuleTypeEnum moduleTypeEnum, EventTypeEnum eventType, String remark) {
        this.eventId = eventId;
        this.eventType = eventType;
        this.moduleTypeEnum = moduleTypeEnum;
        this.remark = remark;
    }

    public static EventIdEnum mustFind(String eventId) {
        for (EventIdEnum idEnum : EventIdEnum.values()) {
            if (StringUtils.equals(idEnum.getEventId(), eventId)) {
                return idEnum;
            }
        }
        return null;
    }

    public boolean ifProcessPayTransfer() {
        return this == READ_CLICK_STORY || this == RECHARGE_CLICK_SELECT ||
                this == RECHARGE_VIEW_POP || this == RECHARGE_SUCC;
    }

    public boolean ifProcessBookTotal() {
        return this == READ_CLICK_STORY || this == READ_OTHER_FIRST || this == READ_OTHER_FIRST_CHAPTER_FINISH ||
                this == READ_OTHER_CHAPTER_UNLOCK || this == READ_OTHER_OPTION_UNLOCK || this == BOOK_OTHER_LIKE || this == BOOK_OTHER_COMMENT;
    }

    public boolean ifProcessBookChapter() {
        return this == READ_VIEW_CHAPTER || this == READ_OTHER_CHAPTER_UNLOCK || this == RECHARGE_SUCC
                || this == READ_VIEW_CHAPTER_FINISH || this == READ_OTHER_OPTION_UNLOCK;
    }

    public boolean ifProcessBookOption() {
        return this == READ_VIEW_OPTION || this == RECHARGE_SUCC || this == READ_CLICK_OPTION || this == READ_EXIT_OPTION;
    }


    public String getEventId() {
        return eventId;
    }

    public ModuleTypeEnum getModuleTypeEnum() {
        return moduleTypeEnum;
    }

    public EventTypeEnum getEventType() {
        return eventType;
    }

    public String getRemark() {
        return remark;
    }


}
